home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / thor / BounceSpam.lha / BounceSpam.thor < prev   
Encoding:
Text File  |  1997-08-10  |  5.0 KB  |  187 lines

  1. /* Add Spammer's Email address to the GetMail configuration file
  2.  
  3.    $VER: BounceSpam.thor V1.5 (10.8.97) ©1997 Roy E Brown
  4.  
  5.    GetMail is © 1996-97 Philip Stokes
  6.  
  7.    This script will add the current message 'from address' to either the
  8.    'Kill Addresses' or the 'Allowed Addresses' section of GetMail's
  9.    configuration file.
  10.  
  11.    The 'Kill' option is useful for automatically adding spammers to your kill
  12.    list, as any mail from these addresses is automatically bounced back to the
  13.    sender without being downloaded to your system.
  14.  
  15.    The 'Allowed' option allows GetMail to receive EMail from the specified
  16.    addresses without asking the user for confirmation first. This option is
  17.    configurable within GetMail - you should read the GetMail documentation
  18.    carefully. You should manually delete the word 'any' from this section if
  19.    you add new addresses.
  20.  
  21.    The script assumes that you have the following 3 lines at the end of your
  22.    existing 'Kill Addresses';
  23.  
  24.    <Blank Line>
  25.    #  ===============================================================
  26.    #  Allowed Addresses
  27.  
  28.    ... and these 2 lines at the end of the file:
  29.  
  30.    <Blank Line>
  31.    # EOF
  32.  
  33.    If you haven't touched these lines at all, then the script should work OK.
  34.  
  35.    This script will only work from within the EMail conference of Thor.
  36.  
  37.    Please change the variable below to reflect the full path location of SMTP.conf */
  38.  
  39. UULibPath="Work:Internet_System/usr/lib/SMTP.conf"    /* Full path to SMTP.conf */
  40.  
  41. /* Please do not alter anything below this line. Thank you */
  42.  
  43. Vers="BounceSpam V1.5 ©1997 Roy E Brown"
  44. lf='0a'x
  45. lines=0
  46. txt=''
  47.  
  48. Signal ON Syntax
  49.  
  50. Options Results
  51.  
  52. Options FailAt 21
  53.  
  54. /* Is Thor active? */
  55. If ~Show('P','THOR.01') Then
  56.   Do
  57.     Say "Thor needs to be available for this script"
  58.     Exit
  59.   End
  60.  
  61. /* Check for Getmail's config file in UULib: */
  62. If ~Exists(UULibPath) Then
  63.   Do
  64.     Address THOR.01
  65.     REQUESTNOTIFY TEXT '"'vers'\n\n   Are you sure that you use GetMail?\n  I cannot find the configuration file.\n\n            UULIB:SMTP.conf" BT "_Exit"'
  66.     Exit
  67.   End
  68.  
  69. /* Check for BBSRead port. Open if necessary */
  70. If ~Show('P','BBSREAD') Then
  71.   Do
  72.     Address Command
  73.     "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  74.     "WaitForPort BBSREAD"
  75.   End
  76.  
  77. /* Let's get the file open and find out how many lines etc */
  78. If Open(config,UULibPath,r)~=1 Then
  79.   Do
  80.     REQUESTNOTIFY TEXT '"'vers'\n\nUnable to open the Getmail configuration file" BT "_Exit"'
  81.     Exit
  82.   End
  83. Else
  84.   Do Until EOF(config)
  85.     Do
  86.       String=Readln(config)
  87.       lines=lines+1
  88.       txt=txt||string||lf
  89.     End
  90.   txt.lines=string
  91.   End
  92.  
  93. Call Close(config)
  94.  
  95. /* Get details of current system and message */
  96. Address THOR.01
  97. CURRENTSYSTEM stem CURRENT
  98. CURRENTMSG stem MSG
  99.  
  100. MDB_DELETED = 5   /* Message is deleted. */
  101.  
  102. Address BBSREAD
  103. READBRMESSAGE CURRENT.BBSNAME '"'CURRENT.CONFNAME'"' MSG.MSGNR HEADSTEM Header DATASTEM msgdata
  104. If RC ~=0 Then Call BBSError
  105.  
  106. If Bittst(MSGDATA.FLAGS,MDB_DELETED) Then
  107.   Do
  108.     Address THOR.01
  109.     REQUESTNOTIFY TEXT '"'vers'\n\nThis message (# 'MSG.MSGNR') has been deleted." BT "_Cancel"'
  110.     Exit
  111.   End
  112.  
  113. Addr=HEADER.FROMADDR
  114.  
  115. /* Do we want to edit the address first? */
  116. Address THOR.01
  117. REQUESTSTRING TITLE '"'Vers'" BT "_Done|_Cancel" ID "'addr'" BODY "Do you wish to edit the address?"'
  118. If RC=5 Then Exit
  119. addr=Result
  120.  
  121. /* What do we want to do - Kill or Accept an address */
  122. Address THOR.01
  123. REQUESTNOTIFY TEXT '"'vers'\n\n   Do you wish to add this address to\n   the ''Kill'' or the ''Accept'' section?\n\n'addr'\n" BT "_Kill|_Accept|_Cancel"'
  124. If Result=0 Then Exit
  125. If Result=1 Then
  126.   Do
  127.     Dest="'Kill'"
  128.     Call Kill
  129.   End
  130. If Result=2 Then
  131.   Do
  132.     Dest="'Accept'"
  133.     Call Accept
  134.   End
  135.  
  136. /* let's write the new configuration file */
  137. Call Open(newfile,UULibPath,w)
  138. Call Writeln(newfile,txt2)
  139.  
  140. /* Let's tell the user what we have done */
  141. Address THOR.01
  142. REQUESTNOTIFY TEXT '"'vers'\n\n The following EMail address has been\n added to the 'dest' section of the\n      GetMail configuration file.\n\n'addr'\n" BT "_Thank You"'
  143.  
  144. Exit
  145.  
  146. /* Let's find the end of the 'Kill Addresses' section and insert the new address */
  147. Kill:
  148. Call Check
  149. Do x=1 To lines
  150.   If txt.x="#  Allowed Addresses" Then
  151.     Do
  152.       x=x-1
  153.       Leave
  154.     End
  155. End
  156.   bar=Length(txt.x)+3
  157.   pos=Index(txt,"#  Allowed Addresses")
  158.   insertpos=pos-bar
  159.   txt2=Insert(addr||lf,txt,insertpos)
  160. Return
  161.  
  162. /* Let's find the end of the 'Allowed Addresses' section and insert the new address */
  163. Accept:
  164.   Call Check
  165.   insertpos=Index(txt,"# EOF")-2
  166.   txt2=Insert(addr||lf,txt,insertpos)
  167. Return
  168.  
  169. /* Let's make sure that the user really wants to do this */
  170. Check:
  171.   Address THOR.01
  172.   REQUESTNOTIFY TEXT '"'vers'\n\n     Are you sure that you wish to\n    add the following EMail address\n     to the 'dest' section of the\n      GetMail configuration file?\n\n'addr'\n" BT "_Positive!|Perhaps Not"'
  173.   If Result=0 Then Exit
  174. Return
  175.  
  176. Syntax:
  177.   Address THOR.01
  178.   REQUESTNOTIFY TEXT '"'vers'\n\nA syntax error ('RC') occurred.\n'ErrorText(RC)'\nin line 'SIGL'" BT "_Exit"'
  179.   Exit
  180. Return
  181.  
  182. BBSError:
  183.   Address THOR.01
  184.   REQUESTNOTIFY TEXT '"'vers'\n\nBBSREAD ERROR\n'BBSREAD.LASTERROR'" BT "_Exit"'
  185.   Exit
  186. Return
  187.